// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults


// listen for scroll
/*
var positionElementInPage = $('notification').offset().top;
$(window).scroll(
	function() {
		if ($(window).scrollTop() >= positionElementInPage) {
			// fixed
			$('notification').addClass("floatable");
		} else {
			// relative
			$('notification').removeClass("floatable");
		}
	}
);
*/
function gererNoticeMessage()
{
	new Effect.Opacity("notice_message", {duration:7, from:1.0, to:0.0});
	$('notice_message').show();
	new Effect.Opacity("trash", {duration:7, from:1.0, to:0.0});
	$('trash').hide();
	$('notice_message').value == '';
}
function gererErrorMessage()
{
	new Effect.Opacity("trash", {duration:7, from:1.0, to:0.0});
	$('trash').hide();
}
new PeriodicalExecuter(function(pe) {
	  new Effect.Opacity("trash", {duration:7, from:1.0, to:0.0});
	  $('trash').hide();
	  new Effect.Opacity("notice_message", {duration:7, from:1.0, to:0.0});
	  $('notice_message').hide();
}, 5);


function gererAffichageMachine(id_salle, affichage)
{
	if($('scroll_machine_'+id_salle).visible()){
		$('scroll_machine_'+id_salle).hide();
		$('lien_affichage_machine_'+id_salle).innerHTML = 'Afficher machines';		
	}else if (affichage == true){
		$('scroll_machine_'+id_salle).show();
		$('lien_affichage_machine_'+id_salle).innerHTML = 'Cacher machines';
	}
}
function suivre_souris(e)
{
	decal_x = 25;
	decal_y = -15;
	if (navigator.appName=="Microsoft Internet Explorer")
	{
		var x = event.x + document.body.scrollLeft;	
		var y = event.y + document.body.scrollTop;
	}
	else
	{
		var x =  e.pageX;
		var y =  e.pageY;
	}
	$("info_bulle_machine").setStyle({'left' : x + decal_x+"px"});
	$("info_bulle_machine").setStyle({'top' : y + decal_y+"px"});
}

function sleep(milliseconds) {
	var start = new Date().getTime();
	while ((new Date().getTime() - start) < milliseconds){
	// Do nothing
	}
}

function afficherLoadingInfoBulle()
{
	$('info_bulle_machine').innerHTML = "<img src='/images/loading.gif' />";
}
